<template>
  <!-- <div class="bg-layer" ref="layer"></div> -->
  <div class="scroll-wrapper" ref="scrollwrapper">
    <scroll
      class="commentList-wrapper"
      :data="comments"
      :listen-scroll="listenScroll"
      :probe-type="probeType"
      ref="list"
      @scroll="scroll"
      :pullup="pullup"
      @scrollToEnd="searchMore"
    >
      <div class="comment-ul">
        <div class="commmnet-item" v-for="(item,index) in comments" :key="index">
          <div class="left-img" v-lazy:background-image="item.avator"></div>
          <div class="right-info">
            <div class="top-info">
              <div class="data">
                <div class="nickname">
                  {{item.nickname}}
                  <i class="iconfont iconvip"></i>
                </div>
                <div class="time">
                  <span>{{item.time}}</span>
                  <!-- <b>精彩评论</b> -->
                </div>
              </div>
              <div class="like-wrap">
                <div class="like">
                  <vue-star animate="animated rubberBand" color="#F05654">
                    <b slot="icon" class="noaninumber">{{item.likedCount}}</b>
                    <i slot="icon" class="iconfont icondianzanfull"></i>
                  </vue-star>
                  <!-- <span v-show="item.likedCount > 0">{{item.likedCount}}</span>
                  <i class="comment" :class="{ commentzan: !item.liked, commentzan1:item.liked}"></i>-->
                </div>
              </div>
            </div>
            <div class="content" v-html="item.content"></div>
          </div>
        </div>
        <van-loading v-show="hasMore" type="circular" color="#fff" vertical>加载更多...</van-loading>
        <p class="nocmt w700" v-if="!comments.length">暂无评论~</p>
      </div>
    </scroll>
  </div>
</template>

<script>
import VueStar from "vue-star";
import { playListMixin } from "@/common/mixin.js";
import Scroll from "@/base/scroll/scroll";
export default {
  mixins: [playListMixin],
  props: {
    comments: {
      type: Array,
      default: []
    },
    hasMore: {
      type: Boolean,
      default: false
    },
    hasMoreHot: {
      type: Boolean,
      default: false
    }
  },
  created() {
    this.probeType = 3;
    this.listenScroll = true;
  },
  data() {
    return {
      scrollY: 0,
      pullup: true
    };
  },
  mounted() {
    // this.minTranslateY = -this.imageHeight + Rev_HEIGHT;
    this.minTranslateY = -300;
  },
  methods: {
    handlePlayList(playlist) {
      const bottom = playlist.length > 0 ? "60px" : "";
      this.$refs.scrollwrapper.style.bottom = bottom;
      this.$refs.list.refresh();
    },
    scroll(pos) {
      this.scrollY = pos.y;
      // console.log(this.scrollY);
    },
    searchMore() {
      if (this.comments.length) {
        this.$emit("scrollBottom");
      }
    },
    refreshBs() {
      this.$refs.list.refresh();
    }
  },
  watch: {
    scrollY(newY) {
      // let translateY = Math.max(this.minTranslateY, newY);
      // this.$refs.layer.style["Transform"] = `translate3d(0,${translateY}px,0)`;
      // this.$refs.layer.style[
      //   "webkitTransform"
      // ] = `translate3d(0,${translateY}px,0)`;
    }
  },
  components: { VueStar, Scroll }
};
</script>

<style lang="less" scoped>
.nocmt {
  font-size: 18px;
}
.comment-ul {
  // position: absolute;
  // z-index: 66;
}
.bg-layer {
  position: relative;
  height: 100%;
  background: #222;
}
.scroll-wrapper {
  position: absolute;
  width: 100%;
  top: 190px;
  bottom: 0;
}
.commentList-wrapper {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  padding-top: 20px;
  height: 100%;
  overflow: hidden;
}
.commmnet-item {
  display: flex;
  align-items: flex-start;
  padding: 0.24rem 0rem 0.24rem 0.25rem;

  .left-img {
    width: 0.88rem;
    height: 0.88rem;
    .bz(cover);
    margin-right: 0.2667rem;
    border-radius: 50%;
    margin-top: 0.29rem;
  }
  .right-info {
    width: 100%;
    padding-bottom: 0.3333rem;
    border-bottom: 1px solid #333;
    .top-info {
      color: #fff;
      line-height: 1.3;
      font-size: 0.3733rem;
      .flex-nowrap-sb(center);
      margin-bottom: 0.13rem;
      .data {
        .time {
          color: #999;
          font-size: 12px;
          margin-top: 0.12rem;
          b {
            margin-left: 5px;
            color: #666;
          }
        }
      }
      .liked {
        color: @mc;
      }
    }
    .content {
      line-height: 1.5;
      font-size: 0.3733rem;
      padding-right: 0.25rem;
      margin-top: 0.1333rem;
    }
  }
}
/deep/.VueStar__ground {
  width: 60px !important;
  height: 60px !important;
}
/deep/.VueStar__decoration {
  width: 100px !important;
  height: 100px !important;
  left: -30% !important;
  top: -30% !important;
  right: inherit !important;
  bottom: inherit !important;
}
/deep/.VueStar {
  position: relative;
  right: 0.3333rem;
}
@-webkit-keyframes rubberBand {
  0% {
    -webkit-transform: scale3d(1, 1, 1);
    transform: scale3d(1, 1, 1);
  }
  30% {
    -webkit-transform: scale3d(1.25, 0.75, 1);
    transform: scale3d(1.25, 0.75, 1);
  }
  40% {
    -webkit-transform: scale3d(0.75, 1.25, 1);
    transform: scale3d(0.75, 1.25, 1);
  }
  50% {
    -webkit-transform: scale3d(1.15, 0.85, 1);
    transform: scale3d(1.15, 0.85, 1);
  }
  65% {
    -webkit-transform: scale3d(0.95, 1.05, 1);
    transform: scale3d(0.95, 1.05, 1);
  }
  75% {
    -webkit-transform: scale3d(1.05, 0.95, 1);
    transform: scale3d(1.05, 0.95, 1);
  }
  100% {
    -webkit-transform: scale3d(1, 1, 1);
    transform: scale3d(1, 1, 1);
  }
}
@keyframes rubberBand {
  0% {
    -webkit-transform: scale3d(1, 1, 1);
    transform: scale3d(1, 1, 1);
  }
  30% {
    -webkit-transform: scale3d(1.25, 0.75, 1);
    transform: scale3d(1.25, 0.75, 1);
  }
  40% {
    -webkit-transform: scale3d(0.75, 1.25, 1);
    transform: scale3d(0.75, 1.25, 1);
  }
  50% {
    -webkit-transform: scale3d(1.15, 0.85, 1);
    transform: scale3d(1.15, 0.85, 1);
  }
  65% {
    -webkit-transform: scale3d(0.95, 1.05, 1);
    transform: scale3d(0.95, 1.05, 1);
  }
  75% {
    -webkit-transform: scale3d(1.05, 0.95, 1);
    transform: scale3d(1.05, 0.95, 1);
  }
  100% {
    -webkit-transform: scale3d(1, 1, 1);
    transform: scale3d(1, 1, 1);
  }
}
/deep/.animated {
  -webkit-animation-duration: 1.66s;
  animation-duration: 1.66s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
}
/deep/.rubberBand {
  -webkit-animation-name: rubberBand;
  animation-name: rubberBand;
}

.like-wrap {
  .flex-row-nowrap(center);
  .like-count {
    font-size: 14px;
  }
  .noaninumber {
    font-size: 12px;
    font-weight: normal;
    margin-right: 2px;
  }
  .animated .noaninumber {
    font-weight: bold;
  }
}
</style>